﻿package gear.ui.model {
	import flash.events.Event;
	import flash.events.EventDispatcher;

	/**
	 * Single Selecteion Model
	 * @author bright
	 * @version 20100430
	 */
	public class SingleSelectionModel extends EventDispatcher {
		protected var _isChange : Boolean;
		protected var _index : int;

		public function SingleSelectionModel() {
			_index = -1;
			_isChange = false;
		}

		public function set index(value : int) : void {
			if (_index == value) return;
			_index = value;
			_isChange = true;
		}

		public function get index() : int {
			return _index;
		}

		public function get isSelected() : Boolean {
			return _index != -1;
		}

		public function clear() : void {
		}

		public function update() : void {
			if (_isChange) {
				_isChange = false;
				dispatchEvent(new Event(Event.CHANGE));
			}
		}
	}
}